import React from 'react';
import Cubox from '../cubic-ui/cubox';

const CuboxInput = ({
  label,
  name,
  type = 'text',
  value,
  onChange,
  placeholder,
  required = false,
  error,
  className = '',
  cornerRadius = 8,
  strokeWidth = 1,
  isOutlined = false,
  ...props
}) => {
  const getColors = () => {
    if (error) {
      return {
        backColor: '#fef2f2', // red-50
        foreColor: '#dc2626', // red-600
        borderColor: '#fca5a5' // red-300
      };
    }
    return {
      backColor: '#ffffff',
      foreColor: '#6b7280', // gray-500
      borderColor: '#d1d5db' // gray-300
    };
  };

  const colors = getColors();

  return (
    <div className={className}>
      <label className="block text-sm font-medium text-gray-700 mb-2">
        {label} {required && '*'}
      </label>
      <div className="relative">
        <Cubox
          cornerRadius={cornerRadius}
          strokeWidth={strokeWidth}
          isOutlined={isOutlined}
          backColor={colors.backColor}
          foreColor={colors.borderColor}
          className="w-full"
          style={{ height: 40 }}
        >
          <input
            type={type}
            name={name}
            value={value}
            onChange={onChange}
            placeholder={placeholder}
            required={required}
            className="w-full h-full px-3 py-2 bg-transparent border-none outline-none text-sm font-mono text-gray-900 placeholder-gray-500"
            style={{
              color: '#111827', // gray-900
              fontSize: '14px'
            }}
            {...props}
          />
        </Cubox>
      </div>
      {error && (
        <p className="mt-1 text-sm text-red-600">{error}</p>
      )}
    </div>
  );
};

export default CuboxInput; 